package main

func balancedStringSplit(s string) int {

	var (
		ls    = 0
		rs    = 0
		total = 0
	)

	for _, v := range s {
		if string(v) == "L" {
			ls++
		} else {
			rs++
		}

		if ls == rs {
			total++
			ls = 0
			rs = 0
		}
	}

	return total
}
